///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
#ifndef __MESH_DATA_H__
#define __MESH_DATA_H__

#include <Config.h>
#include <string>
#include <Model/VertexBuffer.h>

class	VertexIndexBuffer;
class	AABBox;
class	Sphere;

//-----------------------------------------------------------------------------

typedef struct sMeshBuffers
{
	VertexBuffer*		vertexBuffer;
	VertexIndexBuffer*	indexBuffer;
} MeshBuffers;

//-----------------------------------------------------------------------------

class MeshData
{
public:
	/*	Constructor. */
				MeshData( std::string name );

	/*	Destructor. */
	virtual		 ~MeshData();

	/*
	*	Draw the model.
	*/
	void		Draw();

	void		AddMeshBuffers( MeshBuffers &meshBuf );

	/*
	*	Mesh name
	*/
	std::string	GetName()									{	return m_meshName;	}
	bool		IsThisMesh( std::string name )				{	return m_meshName == name;	}

	/*
	*	Bounding elements
	*/
	bool		HasBoundingElement();
	void		generateOBB();
	AABBox*		GetOBB();
	void		generateBoundingSphere();
	Sphere*		GetBoundingSphere();

private:

	void		getMinMax( f32& minx, f32& miny, f32& minz, f32& maxx, f32& maxy, f32& maxz );

	AABBox*			m_obb;
	Sphere*			m_sphere;

	std::string		m_meshName;

	void		sendData( VertexInfo& vi, u8* data );
#if defined(__MGL_USE_GL_POINTER_CALLS__)
	void		sendDataPointer( VertexInfo& vi, u8* data, u8 stride );
#endif

	std::vector<MeshBuffers>	m_buffers;

};

#endif // __MESH_DATA_H__
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
